import React, { ReactElement } from "react";
import { HashRouter, Redirect, Route, Switch } from "react-router-dom";
import AddCategory from "./components/admin/AddCategory";
import AddProduct from "./components/admin/AddProduct";
import AdminDashboard from "./components/admin/AdminDashboard";
import AdminRoute from "./components/admin/AdminRoute";
import Dashboard from "./components/admin/Dashboard";
import PrivateRoute from "./components/admin/PrivateRoute";
import Home from "./components/core/Home";
import NotFound from "./components/core/NotFound";
import Shop from "./components/core/Shop";
import Signin from "./components/core/Signin";
import Signup from "./components/core/Signup";

interface Props {}

export default function Routes(props: Props): ReactElement {
  return (
    <HashRouter>
      <Switch>
        <Route path="/" component={Home} exact></Route>
        <Route path="/shop" component={Shop} exact></Route>
        <Route path="/signin" component={Signin} exact></Route>
        <Route path="/signup" component={Signup} exact></Route>
        <PrivateRoute path="/user/dashboard" component={Dashboard} exact />
        <AdminRoute path="/admin/dashboard" component={AdminDashboard} exact />
        <AdminRoute path="/create/category" component={AddCategory} exact />
        <AdminRoute
          path="/create/product"
          component={AddProduct}
          exact
        ></AdminRoute>
        <Route path="/404" component={NotFound} exact />
        <Redirect to="/404" />
      </Switch>
    </HashRouter>
  );
}
